package controler;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import java.util.Observable;

import javax.swing.JOptionPane;

import template.AbstractListener;
import template.AbstractSystem;

import model.Delivery;
import model.BooleanModel;

public class ResetListener extends AbstractListener implements ActionListener{

	private static final long serialVersionUID = 1L;
	
	public ResetListener(Observable obs1, Observable obs2, Observable obs3){
		addModel(obs1);
		addModel(obs2);
		addModel(obs3);
	}
	
	public void actionPerformed(ActionEvent evt){
		int yes = JOptionPane.showConfirmDialog(AbstractSystem.CURRENTSYSTEM, "Are you sure you want to reset the command?", "Confirmation", JOptionPane.YES_NO_OPTION);
	    if (yes == 0){
			Delivery delivery = (Delivery)getModel(0);
			delivery.removeAllDeliveryElements();
			
			BooleanModel boolModelRestaurantChooser = (BooleanModel)getModel(1);
			BooleanModel boolModelButton = (BooleanModel)getModel(2);
			
			boolModelRestaurantChooser.setValue(true);
			boolModelButton.setValue(false);
	    }
	}
}
